<template>
  <div class="commonTableSty h100">
    <s-table
      :columns="columns"
      :data-source="pcLists"
      :loading="loadingPcLists"
      :showPagination="false"
      :rowClassName="rowClassName"
      :rowKey="(record)=>record.index"
      :offset="34"
      ref="table"
      class="h100"
    >
      <template
        slot-scope="text"
        v-for="column in commonColumns"
        :slot="column.scopedSlots.customRender"
      >
        <table-ellipsis :text="text" :key="column.key"></table-ellipsis>
      </template>
      <template #reportingTime="text">
        <table-ellipsis :text="$commonFun.getDateMinuteStr(text) || '-'"></table-ellipsis>
      </template>
      <template #operation="text,record">
        <a @click="lookNpcEcuDetail(record,record.index)">{{ $t('viewEcuDetail') }}</a>
      </template>
    </s-table>
  </div>
</template>
<script>
import { pcTbColumns } from '../config/list'
import TableEllipsis from '@/components/Ellipsis/TableEllipsis'
import { STable } from '@/components'
export default {
  components: {
    STable,
    TableEllipsis
  },
  props: {
    loadingPcLists: {
      type: Boolean,
      default: false
    },
    activePcIndex: {
      type: Number,
      default: 0
    },
    pcLists: {
      type: Array,
      default () {
        return []
      }
    }
  },
  computed: {
    commonColumns () {
      return pcTbColumns.filter(item => !item.special)
    },
    taskEcuUpdateDictCodeObj () {
      return this.$store.getters.getDictCodeObj('taskEcuUpdateDictCode')
    }
  },
  data () {
    return {
      columns: pcTbColumns
    }
  },
  methods: {
    lookNpcEcuDetail (record, index) {
      this.$emit('changepc', { checkSeqNo: record.checkSeqNo, index })
    },
    rowClassName (record) {
      return record.index === this.activePcIndex ? 'rowSelected' : ''
    }

  }
}
</script>
<style lang="less">
.rowSelected td{
  background: #d8e4e6;
}
</style>
